package org.example.database.Mapper;

import org.apache.ibatis.annotations.*;
import org.example.database.entity.Resume;

import java.util.List;

@Mapper
public interface ResumeMapper {
    /**
     * 插入简历信息
     * @param resume 简历信息
     * @return 影响行数
     */
    @Insert("INSERT INTO resume (name, studentNum, jobIntention, academy, major, educationBackground, " +
            "timeOfEnrollment, timeOfGraduation, workExperience, skill, certificate, assessmentResult) " +
            "VALUES (#{name}, #{studentNum}, #{jobIntention}, #{academy}, #{major}, #{educationBackground}, " +
            "#{timeOfEnrollment}, #{timeOfGraduation}, #{workExperience}, #{skill}, #{certificate}, #{assessmentResult})")
    @Options(useGeneratedKeys = true, keyProperty = "resumeId")
    int insert(Resume resume);

    /**
     * 根据ID查询简历
     * @param resumeId 简历ID
     * @return 简历信息
     */
    @Select("SELECT * FROM resume WHERE resumeId = #{resumeId}")
    Resume selectById(Integer resumeId);

    /**
     * 根据学生ID查询简历列表
     * @param studentNum 学生ID
     * @return 简历列表
     */
    @Select("SELECT * FROM resume WHERE studentNum = #{studentNum}")
    List<Resume> selectByStudentNum(Integer studentNum);

    /**
     * 更新简历信息
     * @param resume 简历信息
     * @return 影响行数
     */
    @Update("UPDATE resume SET name = #{name}, jobIntention = #{jobIntention}, academy = #{academy}, " +
            "major = #{major}, educationBackground = #{educationBackground}, timeOfEnrollment = #{timeOfEnrollment}, " +
            "timeOfGraduation = #{timeOfGraduation}, workExperience = #{workExperience}, skill = #{skill}, " +
            "certificate = #{certificate}, assessmentResult = #{assessmentResult} WHERE resumeId = #{resumeId}")
    int update(Resume resume);

    /**
     * 删除简历
     * @param resumeId 简历ID
     * @return 影响行数
     */
    @Delete("DELETE FROM resume WHERE resumeId = #{resumeId}")
    int deleteById(Integer resumeId);

}
